feat(bigtable): add view_parameters support to BoundStatement#13673
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for view parameters in SQL BoundStatements, introducing the viewParameters field, builder methods to set them, and updating the proto serialization and test proxy deserializer. A review comment correctly points out that the newly added public method setViewParameter(String, Value) lacks direct unit test coverage and provides a helpful code suggestion to test this single-parameter setter.
We need to add support for `view_parameters` in the Java Bigtable client library and the Java Test Proxy to unblock Centigrate testing. Note that the backend Bigtable server currently only supports String typed view parameters. 1. In the Java client library (`BoundStatement.java`): - Update `BoundStatement` and its `Builder` to support storing `view_parameters`. - Implement runtime type validation in `setViewParameter` to check `value.getKindCase() == Value.KindCase.STRING_VALUE`, throwing an `IllegalArgumentException` if a non-String value is passed. - Update `BoundStatement.toProto()` to populate the `view_parameters` field in the `ExecuteQueryRequest` proto. 2. In the Java Test Proxy (`BoundStatementDeserializer.java`): - Update it to extract `view_parameters` from the incoming gRPC `ExecuteQueryRequest` and bind them to the `BoundStatement` before execution (naturally inheriting runtime type validation via delegation). 3. In `BoundStatementTest.java`: - Add unit test verifying `view_parameters` binding and proto conversion. - Add unit test `setViewParameterRejectsNonStringValues` verifying that passing non-String values (int64, bool, unset values, and array values) throws an `IllegalArgumentException`. Note: `bigtable.proto` in `google-cloud-java` already includes `view_parameters` in `ExecuteQueryRequest`. TAG=agy CONV=11853e8d-5cf0-4c6b-8917-b8d6dbac0814 Change-Id: Ie9fb8c3c19d077a99cb3164365752ff7273cbf51
93f98fc to
198cc70
Compare
Change-Id: I9fd4b13273004223d84cdb4df1678a26e851d412
…uilder Change-Id: I2183f39fa9b6197648c84f40eabab770096d6953
Change-Id: Ib5c71c01b359ac43e9ac68716020d6ab821ae7bd
…etStringViewParameter Change-Id: I56289a0414f766bd66db2894e06ae24564429744
… and update deserializer Change-Id: Iccfcdf792365a0c33cdd7383806593b31c7a5bfb
Change-Id: Ib27d1c22cf20ec7752681eab1fefbb181bbeb45e
…proxy module Change-Id: I5b8ac33ea5ef56ea087ecaebaf58857b401f531c
…izerTest Change-Id: Icf860414042548020a65d629862a43a601135afb
1f532a5 to
0e00636
Compare
…cy analyze in CI Change-Id: I6bfc2a16b47797aed6145f785766883f4c21237b
0e00636 to
2d15072
Compare
| Value value = entry.getValue(); | ||
| switch (value.getType().getKindCase()) { | ||
| case STRING_TYPE: | ||
| if (value.getKindCase().equals(KindCase.KIND_NOT_SET)) { |
There was a problem hiding this comment.
Is this right? The kindcase of null string is still string? https://github.com/googleapis/google-cloud-java/blob/main/java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/BoundStatement.java#L213
There was a problem hiding this comment.
I was following the query parameters pattern here https://github.com/ad548/google-cloud-java/blob/f051e2e08aa1306b10c5914fa90cfe34bf2e2920/java-bigtable/test-proxy/src/main/java/com/google/cloud/bigtable/testproxy/BoundStatementDeserializer.java#L50. There is two kindcase - value.getType().getKindCase() and value.getKindCase(). For view_parameters we definitely only care about the first. So yea null string with value.getType().getKindCase() string should be ok.
…tatement Change-Id: I17075aafac540e82501fddaeb5c6e5586fa9d7dc
…is-port-cl-13080 Change-Id: I743dab87f5fddfa338b45c84d2354791d7b933b6
This PR ports the Java client changes supporting
view_parametersinExecuteQueryRequest(originally developed and reviewed internally in CL 13080 / branchadd-view-parameters-support).Changes
view_parameterssupport toBoundStatementand its builder.BoundStatementTestwith unit tests forview_parameters.BoundStatementDeserializerin test-proxy to handleview_parameters.Verification
ExecuteQueryRequestin generated GAPIC proto library already containsview_parameterssupport.google-cloud-bigtableand dependencies.